<template>
  <div>
    <el-card class="box-card" style="margin: 10px 15px 20px 10px;">
      <div slot="header" class="clearfix">
        <span class="blue">基本情况</span>
      </div>
      <div class="text item">
        <baseView ref="baseView"></baseView>
      </div>
    </el-card>
<!--  -->
    <el-card v-if="dataForm.jiangjinFpJjfpdjb && (dataForm.jiangjinFpJjfpdjb.bmJj > 0 || (dataForm.jiangjinFpJjfpdjb.jjcJe*1 > 0&&dataForm.JgfzXq.length>0))" class="box-card"
             style="margin: 10px 15px 20px 10px;">
      <div slot="header" class="clearfix">
        <span class="blue">部门分配详情</span>
        <el-button style="float: right; padding: 3px 0" type="text" v-if="bmShow" @click="bmShow=false">隐藏详情</el-button>
        <el-button style="float: right; padding: 3px 0" type="text" v-if="!bmShow" @click="bmShow=true">显示详情</el-button>
      </div>
      <div class="text item" v-show="bmShow">
        <deptDetails ref="deptDetails"></deptDetails>
      </div>
    </el-card>

    <el-card v-if="dataForm.jiangjinFpJjfpdjb && (dataForm.jiangjinFpJjfpdjb.ygJj > 0 || (dataForm.jiangjinFpJjfpdjb.jjcJe*1 > 0&&dataForm.RyfzXq.length>0))" class="box-card"
             style="margin: 10px 15px 20px 10px;">
      <div slot="header" class="clearfix">
        <span class="blue">员工分配详情</span>
        <el-button style="float: right; padding: 3px 0" type="text" v-if="!grShow" @click="grShow=true">显示详情</el-button>
        <el-button style="float: right; padding: 3px 0" type="text" v-if="grShow" @click="grShow=false">隐藏详情</el-button>
      </div>
      <div class="text item" v-show="grShow">
        <persionDetails ref="persionDetails"></persionDetails>
      </div>
    </el-card>

<!--    <el-card-->
<!--      v-if="dataForm.jiangjinFpJjfpdjb && dataForm.jiangjinFpJjfpdjb.bmJj > 0 && dataForm.jiangjinFpJjfpdjb.fpZt=='审批通过'"-->
<!--      class="box-card" style="margin: 10px 15px 20px 10px;">-->
<!--      <div slot="header" class="clearfix">-->
<!--        <span class="blue">下级分配工作汇总</span>-->
<!--        <el-button style="float: right; padding: 3px 0" type="text" v-if="!xjShow" @click="xjShow=true">显示汇总</el-button>-->
<!--        <el-button style="float: right; padding: 3px 0" type="text" v-if="xjShow" @click="xjShow=false">隐藏汇总</el-button>-->
<!--      </div>-->
<!--      <div class="text item" v-show="xjShow">-->
<!--        <subDeptAssignment ref="subDeptAssignment"></subDeptAssignment>-->
<!--      </div>-->
<!--    </el-card>-->

<!--    <el-card v-if="dataForm.jiangjinFpJjfpdjb && dataForm.jiangjinFpJjfpdjb.fpZt=='审批通过'" class="box-card"-->
<!--             style="margin: 10px 15px 20px 10px;">-->
<!--      <div slot="header" class="clearfix">-->
<!--        <span class="blue">奖金分配员工总汇</span>-->
<!--        <el-button style="float: right; padding: 3px 0" type="text" v-if="!hzShow" @click="hzShow=true">显示总汇</el-button>-->
<!--        <el-button style="float: right; padding: 3px 0" type="text" v-if="hzShow" @click="hzShow=false">隐藏总汇</el-button>-->
<!--      </div>-->
<!--      <div class="text item" v-show="hzShow">-->
<!--        <pubTotal ref="pubTotal"></pubTotal>-->
<!--      </div>-->
<!--    </el-card>-->

    <!-- 根据济民要求暂时去掉2022-2-12
    <el-card class="box-card" style="margin: 10px 15px 20px 10px;">
      <div slot="header" class="clearfix">
        <span class="blue">奖金概况</span>
      </div>
      <div class="text item">
        <moneyDes ref="moneyDes"></moneyDes>
      </div>
    </el-card>
    <el-card class="box-card" style="margin: 10px 15px 20px 10px;">
      <div slot="header" class="clearfix">
        <span class="blue">分配概况</span>
      </div>
      <div class="text item">
        <assignmentDes ref="assignmentDes"></assignmentDes>
      </div>
    </el-card> -->


  </div>
</template>

<script>
import {
  workForlwRescind
} from '@/api/jiangjin/jiangjinfpjjfpdjb'
import baseView from './workflowView/baseView'
import moneyDes from './workflowView/moneyDes'
import assignmentDes from './workflowView/assignmentDes'
import deptDetails from './workflowView/deptDetails'
import persionDetails from './workflowView/persionDetails'
import subDeptAssignment from './workflowView/subDeptAssignment'
import pubTotal from './workflowView/pubTotal'

export default {
  components: {
    baseView,
    moneyDes,
    assignmentDes,
    persionDetails,
    deptDetails,
    subDeptAssignment,
    pubTotal
  },

  data() {
    return {
      dataForm: {},
      bmShow: true,
      grShow: true,
      xjShow: false,
      hzShow: false
    }
  },
  created: function () {

  },
  methods: {
   init(
         fpId
         ) {
      this.loadData(fpId)
    },
    /**
     * 加载数据
     */
    loadData(id) {
      workForlwRescind(id).then(response => {
        var obj = response.data.data;
        this.dataForm = response.data.data;
        //加载奖金详情
        this.getJiangjinFpJjfpdjb(obj);

      });
    },
    //全局个人分配
    getPubTotal(obj) {
      if (this.$refs.pubTotal) {
        this.$nextTick(() => {
          this.$refs.pubTotal.init(obj.grQb, obj.jiangjinFpJjfpdjb.jjxXq);
        });
      }
    },
    //下级分配详情
    getSubDeptAssignment(obj) {
      if (this.$refs.subDeptAssignment) {
        this.$nextTick(() => {
          this.$refs.subDeptAssignment.init(obj.xjBmFpList)
        });
      }
    },
    //部门详情
    getDeptDetails(obj) {
      this.$nextTick(() => {
        if (this.$refs.deptDetails) {
          this.$nextTick(() => {
            // this.$refs.deptDetails.init(obj.bmXq, obj.jiangjinFpJjfpdjb.jjxTjXq)
            this.$refs.deptDetails.init(obj.bmXq, obj.JjxXq, obj.JgfzXq)
          });
        }
      });
    },
    //个人详情
    getPersionDetails(obj) {
      this.$nextTick(() => {
        if (this.$refs.persionDetails) {
          this.$nextTick(() => {
            // this.$refs.persionDetails.init(obj.grXq, obj.jiangjinFpJjfpdjb.jjxTjXq)
            this.$refs.persionDetails.init(obj.grXq, obj.JjxXq, obj.RyfzXq)
          });
        }
      });
    },
    //分配概况
    getAssignmentDes(obj) {
      this.$nextTick(() => {
        this.$refs.assignmentDes.init(obj.fpGk)
      });
    },
    //奖金概况
    getMoenyDes(obj) {
      this.$nextTick(() => {
        this.$refs.moneyDes.init(obj.jjGk)
      });
    },
    //奖金基本情况
    getJiangjinFpJjfpdjb(obj) {
      var jiangjinFpJjfpdjb = obj.jiangjinFpJjfpdjb;
      if (jiangjinFpJjfpdjb && jiangjinFpJjfpdjb.jjxJeXq) {
        jiangjinFpJjfpdjb.jjxJeXq = JSON.parse(jiangjinFpJjfpdjb.jjxJeXq)
      }
      if (jiangjinFpJjfpdjb && jiangjinFpJjfpdjb.jjxXq) {
        jiangjinFpJjfpdjb.jjxXq = JSON.parse(jiangjinFpJjfpdjb.jjxXq)
      }
      if (jiangjinFpJjfpdjb && jiangjinFpJjfpdjb.jjxTjXq) {
        jiangjinFpJjfpdjb.jjxTjXq = JSON.parse(jiangjinFpJjfpdjb.jjxTjXq)
      }
      this.$nextTick(() => {
        this.$refs.baseView.init(jiangjinFpJjfpdjb,obj.jjcYe);
        //加载奖金概况
        // this.getMoenyDes(obj);
        //加载分配概况
        // this.getAssignmentDes(obj);

        //加载部门详情
        this.getDeptDetails(obj);
        //加载个人详情
        this.getPersionDetails(obj);

        // //下级部门
        // this.getSubDeptAssignment(obj);
        // //全局个人分配
        // this.getPubTotal(obj);
      })
    },
    getFormData() {
      var valid = true;
      if (valid) {
        this.$emit("returnFormData", null);
      }
    }
  }
}

</script>

<style>

</style>
